package com.bcntouch.touch2act.Data;

import com.bcntouch.touch2act.Contribute.ContributionStorage;
import com.bcntouch.touch2act.Opine.OpinionStorage;
import com.bcntouch.touch2act.Suggest.SuggestionStorage;
import com.bcntouch.touch2act.User.UserStorage;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {
	public static final String	DATABASE_NAME = "touch2act.db";
	
	public static final int		DATABASE_BASE_VERSION = 1;
	public static final int    	DATABASE_CURRENT_VERSION = DATABASE_BASE_VERSION;
	
	private static DBHelper	helper = null; // for singleton
	
	private DBHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_CURRENT_VERSION);
	}
	
	/**
	 * Static method for singleton helper management
	 * 
	 * @param context
	 * @return
	 */
	public static DBHelper getHelper( Context context ) {
		if ( helper == null )
			helper = new DBHelper( context );
		
		return helper;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		UserStorage.initStorage(db);
		SuggestionStorage.initStorage(db);
		ContributionStorage.initStorage(db);
		OpinionStorage.initStorage(db);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		
	}
}
